﻿@model dynamic

@{
    Layout = null;
    var isChecked = ViewBag.LoginName != null && ViewBag.LoginName != "" ? "checked=checked " : "";
}

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录 - BestEasyCMS后台管理系统</title>
    <!--[if lt IE 9]>
        <script src="~/Contents/Scripts/html5shiv.js"></script>
    <![endif]-->
    <!-- icheck -->
    <link href="~/Contents/Plugins/icheck-1.x/skins/flat/blue.css" rel="stylesheet" />
    <!-- bootstrap -->
    <link href="~/Contents/Plugins/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
    <!-- light-theme -->
    <link href="~/Contents/Css/light-theme.css" rel="stylesheet" />
</head>
<body class='contrast-blue sign-in contrast-background'>
    <div id='wrapper'>
        <div class='application'>
            <div class='application-content'>
                <a href="Login">
                    <div class='icon-heart'></div>
                    <span>BestEasyCMS</span>
                </a>
            </div>
        </div>
        <div class='controls'>
            <div class='caret'></div>
            <div class='form-wrapper'>
                <h1 class='text-center'>登录</h1>
                <form id="loginform" action="#" method="POST">
                    @Html.AntiForgeryToken()
                    <input type="text" class="form-control" name="loginName" id="loginName" value="@ViewBag.LoginName" placeholder="登录名">
                    <input type="password" class="form-control" name="password" id="password" placeholder="密码">
                    <div class="checkbox">
                        <label style="padding-left: 0;">
                            <input type="checkbox" name="rememberMe" @isChecked>
                            记住我？
                        </label>
                    </div>
                    <button class="btn btn-block btn-default" name="button" type="submit">登录</button>
                </form>
                <div class='text-center'>
                    <hr class='hr-normal' />
                    <label style="color: #00acec;">
                        @DateTime.Now.Year © BestEasyCMS. <a style="color: #00acec;" target="_black" href="http://www.zhengjinfan.cn">www.zhengjinfan.cn</a>
                    </label>
                </div>
            </div>
        </div>
    </div>
    <script src="~/Contents/Scripts/jquery.min.js"></script>
    <script src="~/Contents/Plugins/icheck-1.x/icheck.min.js"></script>
    <script src="~/Contents/Scripts/jquery.validate.min.js"></script>
    <script src="~/Contents/Scripts/jquery.serializeObject.js"></script>
    <script src="~/Contents/Plugins/layer/layer.js"></script>
    <script>
        $(document).ready(function () {
            $('input').iCheck({
                checkboxClass: 'icheckbox_flat-blue'
            });
            function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]); return null;
            }
            /*--------------Login Validate Start--------------*/
            $("#loginform").validate({
                rules: {
                    loginName: "required",
                    password: {
                        required: true,
                        rangelength: [8, 20]
                    }
                },
                messages: {
                    loginName: "请输入用户名！",
                    password: {
                        required: "请输入密码！",
                        rangelength: "请输入{0}到{1}之间的密码！"
                    }
                }, submitHandler: function (form) {
                    //获取防伪标记
                    var token = $('input[name=__RequestVerificationToken]').val();
                    var params = $(form).serializeObject();
                    params.__RequestVerificationToken = token;
                    var returnUrl = getQueryString("ReturnUrl");
                    $.ajax({
                        type: "POST",
                        url: "Login",
                        data: params,
                        success: function (result) {
                            if (result.rel) {
                                if (returnUrl == null)
                                    location.href = "/BestEasyAdmin/Default/";
                                else {
                                    location.href = returnUrl;
                                }
                            } else {
                                layer.alert(result.msg, { icon: 2, title: '温馨提示' });
                            }
                        },
                        error: function (data) {
                            layer.alert("Error：内部错误，请刷新重试或联系管理员！", { icon: 2, title: '温馨提示' });
                        }
                    });
                }
            });
            /*--------------Login Validate End--------------*/
        });
    </script>
</body>
</html>
